<?
global $db,$topdir;
$link = $params["link"];
$e=$params;
	
if(($oldid=$_REQUEST["oldid"]) != ($midid=$params["id"])) $check = 1;

if ($_POST["content"]) {
	$content = $_POST["content"];
	$safehtmldir = "$topdir/ext/safehtml/classes/";
	define('XML_HTMLSAX3', $safehtmldir);
	require_once "{$safehtmldir}safehtml.php";
	$safehtml =& new safehtml();
	$content = $safehtml->parse($content);
	$content = str_replace("</td>","",$content);
	$content = str_replace("</tr>","",$content);
	$e = array(
		"changes"=>$_POST["changes"],
		"content"=>$content,
		"link"=>$link,
		);
	$newid = _wiki_insert($e);
	
	if ($check) { header("Location: conflict.php?link=$link&oldid=$oldid&midid=$midid&newid=$newid"); die; }
	header("Location: $link"); die;
	}

$e["oldid"]=$e["id"];
inc_incfile("form3.php",array(
	"record"=>$e,
	"fields"=>array(
		"oldid"=>array(
			"type"=>"default",
			"display"=>"hidden",
			),
		"content"=>array(
			"type"=>"textarea",
			"title"=>"Content",
			"rows"=>12,
			"cols"=>80,
			),
		"changes"=>array(
			"type"=>"default",
			"title"=>"Changes",
			),
		),
	"upload"=>1,
	"actions"=>array(
		"Continue"=>"",
		),
	));
	
?>